package com.yingjie.yingjieorder.config.orderMq;


import com.yingjie.yingjieorder.common.RabiitMqConst;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfig {

    //定义直连交换机
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(RabiitMqConst.EXCHANGE);
    }

    //定义队列
    @Bean
    public Queue queueA(){
        return new Queue(RabiitMqConst.ORDER_QUEUE);
    }
    //绑定交换机和队列
    @Bean
    public Binding bindingA(DirectExchange directExchange,Queue queueA){
        return BindingBuilder.bind(queueA).to(directExchange).withQueueName();
    }


}
